import request from '../utils/request'

export function get() {
  return request<Classification[]>({
    url: '/classification/get',
    method: 'GET'
  })
}

export function getChildren(id: number) {
  return request<Classification>({
    url: '/classification/getbyid?id=' + id,
    method: 'GET'
  })
}

export function add(data: unknown) {
  return request({
    url: '/classification/add',
    method: 'POST',
    data
  })
}

export function addChildren(data: unknown) {
  return request({
    url: '/classificationChildren/add',
    method: 'POST',
    data
  })
}

export function deleteById(id: number) {
  return request({
    url: '/classification/delete?id=' + id,
    method: 'DELETE'
  })
}

export function deleteChildrenById(id: number) {
  return request({
    url: '/classificationChildren/delete?id=' + id,
    method: 'DELETE'
  })
}

export function update(data: unknown, id: number) {
  return request({
    url: '/classification/update?id=' + id,
    method: 'PUT',
    data
  })
}

export function updateChildren(data: unknown, id: number) {
  return request({
    url: '/classificationChildren/update?id=' + id,
    method: 'PUT',
    data
  })
}
